from .base import BaseModel, TimestampMixin
from .enums import OrderStatus
from tortoise import fields

class Order_Mo(BaseModel, TimestampMixin):
    """
    订单模型 - 存储AGV系统中的订单信息
    """
    order_name = fields.CharField(max_length=20, unique=True, description="订单名称")
    user_id = fields.IntField(null=True, description="用户ID")
    type = fields.CharField(max_length=20, null=True, description="订单类型")
    status = fields.CharEnumField(OrderStatus, max_length=20, description="订单状态")
    car_index = fields.IntField(null=True, description="关联的AGV编号")
    priority = fields.IntField(null=True, description="订单优先级")
    order_station_from = fields.ForeignKeyField("models.Map_Node_Mo", related_name="orders_from", description="当前站ID")
    order_station_to = fields.ForeignKeyField("models.Map_Node_Mo", related_name="orders_to", description="目标站ID")
    current_node = fields.ForeignKeyField("models.Map_Node_Mo", null = True, related_name="current_orders", description="当前节点ID")
    next_node = fields.ForeignKeyField("models.Map_Node_Mo", null = True, related_name="next_orders", description="下一个节点ID")
    
    class Meta:
        table = "orders"
        table_description = "AGV系统订单表"
